﻿@inherits EditOperationDialogBase<EmailTemplateDto, Guid, EmailLocalResource>
@if (_editModel != null)
{
    <Form Loading="@_dialogLoading.Value"
          Model="@_editModel"
          LabelCol="new ColLayoutParam { Span = 6 }"
          WrapperCol="new ColLayoutParam { Span = 18 }"
          OnFinish="OnFormFinish"
          Context="model">
        <FormItem Label="@Localizer[EmailLocalResource.Name]">
            <Input @bind-Value="@model.Name" />
        </FormItem>
        <FormItem Label="@Localizer[EmailLocalResource.FromName]">
            <Input @bind-Value="@model.FromName" />
        </FormItem>
        <FormItem Label="@Localizer[EmailLocalResource.Remark]">
            <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Remark"></TextArea>
        </FormItem>
        <FormItem Label="@Localizer[EmailLocalResource.Example]">
            <TextArea AutoSize="true" MinRows="2" MaxRows="6" @bind-Value="@model.Example"></TextArea>
        </FormItem>
        <FormItem Label="@Localizer[EmailLocalResource.SubjectTemplate]">
            <TextArea AutoSize="true" MinRows="2" MaxRows="10" @bind-Value="@model.SubjectTemplate"></TextArea>
        </FormItem>
        <FormItem Label="@Localizer[EmailLocalResource.ContentTemplate]">
            <TextArea AutoSize="true" MinRows="5" MaxRows="10" @bind-Value="@model.ContentTemplate"></TextArea>
        </FormItem>
        <FormItem Label="@Localizer[EmailLocalResource.IsHtml]">
            <Switch @bind-Value="@model.IsHtml"></Switch>
        </FormItem>
        <FormItem Label="@Localizer[SharedLocalResource.IsLocked]">
            <Switch @bind-Value="@model.IsLocked"></Switch>
        </FormItem>
        @if (this.Options.Type.Equals(OperationDialogInputType.Edit) || this.Options.Type.Equals(OperationDialogInputType.Select))
        {
            <FormItem Label="@Localizer[SharedLocalResource.CreatedTime]">
                <span>@model.CreatedTime.ToString(ClientConstant.DateTimeFormat)</span>
            </FormItem>
            <FormItem Label="@Localizer[SharedLocalResource.UpdatedTime]">
                <span>@model.UpdatedTime?.ToString(ClientConstant.DateTimeFormat)</span>
            </FormItem>
        }
        <FormItem WrapperColOffset="6" WrapperColSpan="18">
            <Space>
                @if (!OperationDialogInputType.Select.Equals(this.Options.Type))
                {
                    <SpaceItem>
                        <Button Type="@ButtonType.Primary" HtmlType="submit">
                            @Localizer[SharedLocalResource.Save]
                        </Button>
                    </SpaceItem>
                }
                <SpaceItem>
                    <Button OnClick="_=>OnFormCancel()">
                        @Localizer[SharedLocalResource.Cancel]
                    </Button>
                </SpaceItem>
            </Space>
        </FormItem>
    </Form>
}
